<!--{template lyear:header_simple_start}-->
<style>
	.bs-top-container,.sidebar-header {
		background-color: #fff;
	}
	.navbar-right .nav-link{
		color: inherit;
	}
	.sidebar-header a{
		color: inherit !important;
	}
	.bs-main-container{
		padding-left:0;
	}
	.ui-sortable-helper{
		border:1px solid transparent;
		opacity: 0.6;
	}
	.ui-state-default{
		display: inline-block;
	}
	.card-market:hover,.card-market:focus-within{box-shadow:0px 0px 12px rgba(0, 0, 0, 0.12);transform:translatey(-5px)}
	.app-icon {
		width: 64px;
		height: 64px;
		margin: 0 auto 1rem;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
<!--{template lyear:header_simple_noleft_end}-->
<main class="bs-main-container" style="padding-left: 0;">
	<div class="container-fluid">
		<div class="card d-flex flex-wrap justify-content-between">
			<div class="card-body">
				<div class="display-4 fs-4 fw-bold mb-1">{$_G['username']}，<span id="greeting">早上好！</span></div>
				<p>您于<!--{eval echo dgmdate($userstatus['lastvisit'])}-->登录。当前时间：<span id="current-date"></span><span class="ps-2" id="weekday"></span><span class="ps-2" id="time">00:00:00</span>。</p>
			</div>
		</div>
		<div class="row card-banner bg-white">
			<div class="card mb-0 shadow-none">
				<div class="card-body">
					<div class="d-flex justify-content-between">
					<span class="avatar-md rounded-circle avatar-box text-white bg-yellow">
						<i class="mdi mdi-cloud-outline fs-4"></i>
					</span>
					<span class="fs-4 text-truncate">$space['fusesize']/$space['fmaxspacesize']</span>
					</div>
					<div class="text-end">空间使用</div>
				</div>
			</div>
		</div>
		<!--{if $applist_1}-->
		<div class="row ui-sortable">
			<!--{loop $applist_1 $key $value}-->
			<div class="popup-index-li col-xxl-2 col-xl-3 col-lg-3 col-md-4 col-sm-6 col-12" data-appid="$value[appid]">
				<a <!--{if $value['open']}-->target="_blank"<!--{/if}--> href="$value[url]" title="$value[appname]" class="card card-market border m-2">
				<div class="card-body text-center">
					<img src="$value[appico]" class="app-icon">
					<div class="card-title text-body text-truncate">$value[appname]</div>
				</div>
				</a>
			</div>
			<!--{/loop}-->
		</div>
		<!--{/if}-->
		<footer class="text-center text-muted m-3 mt-5">
			<!--{template lyear:copyright}-->
		</footer>
	</div>
</div>
</main>
<script type="text/javascript">
	jQuery(document).ready(function(){
		jQuery('.ui-sortable').sortable({
			placeholder: "ui-state-default col-xxl-2 col-xl-3 col-lg-3 col-md-4 col-sm-6 col-12 border card",
			items: "div.popup-index-li",
			stop: function(event, ui) {
				var appids=[];
				jQuery('.popup-index-li').each(function(){
					appids.push(jQuery(this).data('appid'));
				});
				jQuery.post('{MOD_URL}&do=saveIndex',{"appids":appids});
			}
		});
	});
</script>
<script type="text/javascript" src="static/jquery/jquery-ui.js?{VERHASH}"></script>
<script>
	// 服务器时间初始化
	var serverTimestamp = '$servertime'; 
	
	// 客户端加载时间
	var clientTimestampAtLoad = Date.now();
	
	// 计算时间偏移量
	var timeOffset = serverTimestamp - clientTimestampAtLoad;
	
	// 获取当前服务器时间
	function getServerTime() {
		return new Date(Date.now() + timeOffset);
	}
	// 为IE添加String.prototype.padStart的polyfill
	if (!String.prototype.padStart) {
		String.prototype.padStart = function padStart(targetLength, padString) {
			targetLength = targetLength >> 0; //floor if number or convert non-number to 0;
			padString = String(typeof padString !== 'undefined' ? padString : ' ');
			if (this.length >= targetLength) {
				return String(this);
			} else {
				targetLength = targetLength - this.length;
				if (targetLength > padString.length) {
					padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
				}
				return padString.slice(0, targetLength) + String(this);
			}
		};
	}

	$(document).ready(function() {
		// 时间格式和显示选项
		var showSeconds = true;
		
		// 更新问候语
		function updateGreeting() {
			var now = getServerTime();
			var hour = now.getHours();
			var greeting = '';
			
			if (hour < 6) {
				greeting = '凌晨好！';
			} else if (hour < 9) {
				greeting = '早上好！';
			} else if (hour < 12) {
				greeting = '上午好！';
			} else if (hour < 14) {
				greeting = '中午好！';
			} else if (hour < 18) {
				greeting = '下午好！';
			} else if (hour < 22) {
				greeting = '晚上好！';
			} else {
				greeting = '夜深了！';
			}
			
			$('#greeting').text(greeting);
		}
		
		// 更新日期显示
		function updateDate() {
			var now = getServerTime();
			var options = {year: 'numeric', month: 'long', day: 'numeric' };
			var dateString = now.toLocaleDateString('zh-CN', options);
			var weekday = now.toLocaleDateString('zh-CN', { weekday: 'long' });
			$('#current-date').text(dateString);
			$('#weekday').text(weekday);
		}
		
		// 更新时间显示
		function updateTime() {
			var now = getServerTime();
			var hours = now.getHours();
			var minutes = now.getMinutes();
			var seconds = now.getSeconds();
			var ampm = '';
			
			// 补零
			hours = hours.toString().padStart(2, '0');
			minutes = minutes.toString().padStart(2, '0');
			seconds = seconds.toString().padStart(2, '0');
			
			// 构建时间字符串
			var timeString = hours + ':' + minutes;
			if (showSeconds) {
				timeString += ':' + seconds;
			}
			
			// 应用到DOM
			$('#time').text(timeString);
		}
		
		// 初始化所有显示
		function initializeDisplay() {
			updateGreeting();
			updateDate();
			updateTime();
		}
		
		// 每秒更新时间
		setInterval(function() {
			updateTime();
		}, 1000);
		
		// 每分钟更新日期和进度
		setInterval(function() {
			updateDate();
		}, 60000);
		
		// 每小时更新问候语
		setInterval(updateGreeting, 3600000);
		
		// 初始化显示
		initializeDisplay();
	});
</script>
<!--{template lyear:footer_simple}-->